package class101To110;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class ExpandKMP {

    public static int MAXN = 20000001;

    public static int[] z = new int[MAXN];

    public static int[] e = new int[MAXN];

    public static void zArray(char[] s, int n) {
        z[0] = n;
        for (int i = 1, c = 1, r = 1, len; i < n; i++) {
            len = r > i ? Math.min(r - i, z[i - c]) : 0;
            while (i + len < n && s[len] == s[i + len]) {
                len++;
            }
            if (i + len > r) {
                r = i + len;
                c = i;
            }
            z[i] = len;
        }
    }

    public static void eArray(char[] a, char[] b, int n, int m) {
        for (int i = 0, c = 0, r = 0, len; i < n; i++) {
            len = r > i ? Math.min(r - i, z[i - c]) : 0;
            while (i + len < n && len < m && a[i + len] == b[len]) {
                len++;
            }
            if (i + len > r) {
                c = i;
                r = i + len;
            }
            e[i] = len;
        }
    }

    public static long eor(int[] a, int n) {
        long res = 0;
        for (int i = 0; i < n; i++) {
            res ^= (long) (i + 1) * (a[i] + 1);
        }
        return res;
    }


    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        char[] a = in.readLine().toCharArray();
        char[] b = in.readLine().toCharArray();
        zArray(b, b.length);
        eArray(a, b, a.length, b.length);
        out.println(eor(z, b.length));
        out.println(eor(e, a.length));
        out.flush();
        out.close();
        in.close();
    }
}
